<!-- 编辑弹窗 -->
<template>
  <a-modal title="编辑分享" :visible="visible" okText="保存" @ok="handleOk" @cancel="visible = false" destroyOnClose>
    <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
      <a-form-model-item label="分享标题">
        <a-input v-model="form.desc" aria-placeholder="请输入分享标题" />
      </a-form-model-item>
      <a-form-model-item label="分享图">
        <UploadImg v-model="form.iconUrl" warehouse cropper :width="250" :height="200" :cropperEnlarge="2">
          <template #tips>500*400</template>
        </UploadImg>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import UploadImg from '@/components/UpFile/uploadImg'
import { editConfigAppBasisData } from '@/api/web/web'
export default {
  components: {
    UploadImg,
  },
  data() {
    return {
      visible: false,
      labelCol: { span: 4 },
      wrapperCol: { span: 16 },
      form: {
        id: undefined,
        desc: undefined,
        iconUrl: undefined,
      },
    }
  },
  computed: {},
  watch: {},
  methods: {
    show(row) {
      Object.keys(this.form).forEach((k) => {
        this.form[k] = row[k]
      })
      this.visible = true
    },
    async handleOk() {
      let { code, msg } = await editConfigAppBasisData({ ...this.form, type: 4 })
      this.$message[code === 0 ? 'success' : 'error'](msg)
      if (code === 0) {
        this.$emit('success')
        this.visible = false
      }
    },
  },
  created() {},
  mounted() {},
}
</script>
<style scoped>
</style>